package com.codingclub.domain.service.impl;

import com.codingclub.domain.bo.SubjectCategoryBO;
import com.codingclub.domain.convert.SubjectCategoryConverter;
import com.codingclub.domain.service.SubjectCategoryDomainService;
import com.codingclub.infra.basic.entity.SubjectCategory;
import com.codingclub.infra.basic.service.SubjectCategoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SubjectCategoryDomainServiceImpl implements SubjectCategoryDomainService {
    @Resource
    private SubjectCategoryService subjectCategoryService;

    public void add(SubjectCategoryBO subjectCategoryBO){
        SubjectCategory subjectCategory = SubjectCategoryConverter.INSTANCE.covertBoToEntity(subjectCategoryBO);
        subjectCategoryService.insert(subjectCategory);
    }

    @Override
    public List<SubjectCategoryBO> queryCategory(SubjectCategoryBO subjectCategoryBO) {
        SubjectCategory subjectCategory = SubjectCategoryConverter.INSTANCE.covertBoToEntity(subjectCategoryBO);
        List<SubjectCategory> entityList=subjectCategoryService.queryCategory(subjectCategory);
        return SubjectCategoryConverter.INSTANCE.covertBoToEntity(entityList);
    }

}
